<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function removeDuplicate(arr) {
        return arr.filter((item, index) => {
          return arr.indexOf(item) === index;
        });
      }
      const arr = [1, 1, 2, 2, 3, 3];
      removeDuplicate(arr);
      // console.log(removeDuplicate(arr));

      const obj = {};
      Object.defineProperty(obj, "a", {
        configurable: false,
        enumerable: false,
        get() {
          return arr[0];
        },
      });

      let result = function (obj) {
        // 如果是空对象则不会执行循环
        for (let key in obj) {
          return false; //若不为空，可遍历，返回false
        }
        return true;
      };

      console.log(obj);
      console.log(obj.a);
      console.log(result(obj)); // true
      console.log(JSON.stringify(obj) === "{}"); // true
      console.log(Object.keys(obj).length === 0); // true
      // 可以读取不可枚举的属性
      console.log(Object.getOwnPropertyNames(obj)); // false
    </script>
  </body>
</html>
